Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / desktop / src / main / kotlin / org / meshtastic / desktop / DesktopNotificationManager.kt

Displaying Raw • Download

desktop/src/main/kotlin/org/meshtastic/desktop/DesktopNotificationManager.kt 9acdf5309f8f0ab96b30d6505bdac5e93a3bb72c (9acdf530) Text, 3.61 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.desktop

Tff7b72import T7ee787co.touchlab.kermit.Logger
Tff7b72import T7ee787kotlinx.coroutines.flow.MutableSharedFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.SharedFlow
Tff7b72import T7ee787kotlinx.coroutines.flow.asSharedFlow
Tff7b72import T7ee787org.meshtastic.core.repository.Notification
Tff7b72import T7ee787org.meshtastic.core.repository.NotificationManager
Tff7b72import T7ee787org.meshtastic.core.repository.NotificationPrefs
Tff7b72import T7ee787androidx.compose.ui.window.Notification Tff7b72as Te6edf3ComposeNotification

T8b949e/**
* Desktop notification manager that bridges domain [Notification] objects to Compose Desktop tray notifications.
*
* Notifications are emitted via [notifications] and collected by the tray composable in [Main.kt]. Respects user
* preferences for message, node-event, and low-battery categories.
*
* Registered manually in `desktopPlatformStubsModule` -- do **not** add `@Single` to avoid double-registration with the
* `@ComponentScan("org.meshtastic.desktop")` in [DesktopDiModule][org.meshtastic.desktop.di.DesktopDiModule].
*/
Tff7b72class T56d364DesktopNotificationManagerTb4b4b4(Tff7b72private Tff7b72val Te6edf3prefsTb4b4b4: Te6edf3NotificationPrefsTb4b4b4) Tb4b4b4: Te6edf3NotificationManager Tb4b4b4{
Tff7b72init Tb4b4b4{
Te6edf3LoggerTb4b4b4.Te6edf3i Tb4b4b4{ Ta5d6ff"Ta5d6ffDesktopNotificationManager initializedTa5d6ff" Tb4b4b4}
Tb4b4b4}

Tff7b72private Tff7b72val Te6edf3_notifications Tff7b72= Te6edf3MutableSharedFlowTff7b72<Te6edf3ComposeNotificationTff7b72>Tb4b4b4(Te6edf3extraBufferCapacity Tff7b72= T79c0ff1T79c0ff0Tb4b4b4)

T8b949e/** Flow of Compose [ComposeNotification] objects to be forwarded to [TrayState.sendNotification]. */
Tff7b72val Te6edf3notificationsTb4b4b4: Te6edf3SharedFlowTff7b72<Te6edf3ComposeNotificationTff7b72> Tff7b72= Te6edf3_notificationsTb4b4b4.Te6edf3asSharedFlowTb4b4b4(Tb4b4b4)

Tff7b72override Tff7b72fun Td2a8ffdispatchTb4b4b4(Te6edf3notificationTb4b4b4: Te6edf3NotificationTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3enabled Tff7b72=
Tff7b72when Tb4b4b4(Te6edf3notificationTb4b4b4.Te6edf3categoryTb4b4b4) Tb4b4b4{
Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3Message Tff7b72-Tff7b72> Te6edf3prefsTb4b4b4.Te6edf3messagesEnabledTb4b4b4.Te6edf3value
Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3NodeEvent Tff7b72-Tff7b72> Te6edf3prefsTb4b4b4.Te6edf3nodeEventsEnabledTb4b4b4.Te6edf3value
Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3Battery Tff7b72-Tff7b72> Te6edf3prefsTb4b4b4.Te6edf3lowBatteryEnabledTb4b4b4.Te6edf3value
Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3Alert Tff7b72-Tff7b72> Tff7b72true
Te6edf3NotificationTb4b4b4.Te6edf3CategoryTb4b4b4.Te6edf3Service Tff7b72-Tff7b72> Tff7b72true
Tb4b4b4}

Te6edf3LoggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffDesktopNotificationManager dispatch: category=Tffd700${Te6edf3notificationTb4b4b4.Te6edf3categoryTffd700}Ta5d6ff, enabled=Tffd700$Te6edf3enabledTa5d6ff" Tb4b4b4}

Tff7b72if Tb4b4b4(Tff7b72!Te6edf3enabledTb4b4b4) Tff7b72return

Tff7b72val Te6edf3composeType Tff7b72=
Tff7b72when Tb4b4b4(Te6edf3notificationTb4b4b4.Te6edf3typeTb4b4b4) Tb4b4b4{
Te6edf3NotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3None Tff7b72-Tff7b72> Te6edf3ComposeNotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3None
Te6edf3NotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Info Tff7b72-Tff7b72> Te6edf3ComposeNotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Info
Te6edf3NotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Warning Tff7b72-Tff7b72> Te6edf3ComposeNotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Warning
Te6edf3NotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Error Tff7b72-Tff7b72> Te6edf3ComposeNotificationTb4b4b4.Te6edf3TypeTb4b4b4.Te6edf3Error
Tb4b4b4}

Tff7b72val Te6edf3success Tff7b72= Te6edf3_notificationsTb4b4b4.Te6edf3tryEmitTb4b4b4(Te6edf3ComposeNotificationTb4b4b4(Te6edf3notificationTb4b4b4.Te6edf3titleTb4b4b4, Te6edf3notificationTb4b4b4.Te6edf3messageTb4b4b4, Te6edf3composeTypeTb4b4b4)Tb4b4b4)
Te6edf3LoggerTb4b4b4.Te6edf3d Tb4b4b4{ Ta5d6ff"Ta5d6ffDesktopNotificationManager emit: success=Tffd700$Te6edf3successTa5d6ff, title=Tffd700${Te6edf3notificationTb4b4b4.Te6edf3titleTffd700}Ta5d6ff" Tb4b4b4}
Tb4b4b4}

Tff7b72override Tff7b72fun Td2a8ffcancelTb4b4b4(Te6edf3idTb4b4b4: Tffa657IntTb4b4b4) Tb4b4b4{
T8b949e// Desktop tray notifications cannot be cancelled once sent via TrayState.
Tb4b4b4}

Tff7b72override Tff7b72fun Td2a8ffcancelAllTb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Desktop tray notifications cannot be cleared once sent via TrayState.
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.06s